<?php
/**
* @version		$Id: view.html.php 5 2011-10-29 10:13:13Z netix.mail@gmail.com $
* @package		ALM Hotel Menager	
* @subpackage	com_almhm
* @author		ALM Studio
* @copyright	Copyright 2011 ALM Studio. All rights reserved
* @licence		Commercial
*/

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');

class AlmHmViewOblast extends JView
{

	protected $form;
	protected $item;
	protected $state;

	public function display($tpl = null) 
	{
		$this->form		= $this->get('Form');
		$this->item		= $this->get('Item');
		$this->state	= $this->get('State');

		if (count($errors = $this->get('Errors'))) 
		{
			JError::raiseError(500, implode('<br />', $errors));
			return false;
		}

		$this->addToolBar();
		
		parent::display($tpl);
		$this->setDocument();
	}

	protected function addToolBar() 
	{
		JRequest::setVar('hidemainmenu', true);
		$isNew = ($this->item->OblastId == 0);
		JToolBarHelper::title($isNew ? JText::_('COM_ALMHM_NOVA_OBLAST') : JText::_('COM_ALMHM_IZMJENA_OBLASTI'), 'oblast');
		JToolBarHelper::apply('oblast.apply', 'COM_ALMHM_SPREMI');
		JToolBarHelper::save('oblast.save', 'COM_ALMHM_SPREMI_I_ZATVORI');
		JToolBarHelper::custom('oblast.save2new', 'save-new.png', 'save-new_f2.png', 'COM_ALMHM_SPREMI_I_NOVI', false);
		JToolBarHelper::cancel('oblast.cancel', $isNew ? 'COM_ALMHM_OBUSTAVI' : 'cancel');
	}

	protected function setDocument() 
	{
		$isNew = ($this->item->OblastId < 1);
		$document = JFactory::getDocument();
		$document->setTitle($isNew ? JText::_('COM_ALMHM_NOVA_OBLAST_SITE_TITLE') : JText::_('COM_ALMHM_IZMJENA_OBLASTI_SITE_TITLE'));
	}
}